package com.cie2.map.pages;

import java.util.ArrayList;
import java.util.List;

import org.apache.tapestry5.annotations.Component;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.corelib.components.Form;

import com.cie2.map.entities.MapData;

public class DataEditor {

	@Component(id = "dataedit")
	private Form _form;

	@Property
	private List dataHolders;
	
	@Property
	private MapData data;

	void onPrepare() {
		dataHolders = new ArrayList<MapData> ();
		MapData mapData = new MapData();
		mapData.setId(1L);
		mapData.setMapObjectId(1L);
		mapData.setValue("10000");
		dataHolders.add(mapData);
		mapData = new MapData();
		mapData.setId(2L);
		mapData.setMapObjectId(2L);
		mapData.setValue("22000");
		dataHolders.add(mapData);
		
	}
// what is the different using a model and value encoder ? 	
//	@SuppressWarnings("unchecked")
//	public ValueEncoder getEncoder() {
//		return new ValueEncoder<PersonHolder>() {
//
//			public String toClient(PersonHolder value) {
//				Long key = value.getKey();
//				return key.toString();
//			}
//
//			public PersonHolder toValue(String keyAsString) {
//				Long key = new Long(keyAsString);
//				for (PersonHolder holder : _personHolders) {
//					if (holder.getKey().equals(key)) {
//						return holder;
//					}
//				}
//				throw new IllegalArgumentException("Received key \"" + key
//						+ "\" which has no counterpart in this collection: " + _personHolders);
//			}
//		};
//	}

}
